package com.tinysand.advert.entity.condition;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * 推广单元的关键词限制（关键词匹配）类；只有请求中带有指定的关键字才会返回对应广告
 *
 * Created By TINY
 * Create Time 2020/2/15
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "ad_unit_keyword")
@EntityListeners(AuditingEntityListener.class) // 使用JPA审计自动维护日期
public class AdUnitKeyWord {

    /* 推广单元维度表自增主键 */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    /* 关联推广单元的主键 */
    @Column(name = "unit_id", nullable = false)
    private Long unitId;

    /* 推广维度关键字 */
    @Column(name = "keyword", nullable = false)
    private String keyword;

    public AdUnitKeyWord(Long unitId, String keyword) {
        this.unitId = unitId;
        this.keyword = keyword;
    }
}
